﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using myBoard.Framework;
using System.Diagnostics;
using System.Reflection;

namespace ClockMagnet
{
	/// <summary>
	/// Interaction logic for UserControl1.xaml
	/// </summary>
	public partial class UserControl1 : IMagnet
	{
		public UserControl1()
		{
			this.InitializeComponent();
		}

        ~UserControl1()
        {
            Debug.WriteLine("Destroying Clock");
        }

        #region IMagnet Members

        public string StoreID 
        {
            get
            { return "{B152161F-4143-4a78-A8AF-E675C4BB693F}"; }
        }

        public BitmapImage Icon
        {
            get
            {
                return ResourcesAccess.GetBitmapImageFromResource(Assembly.GetExecutingAssembly(), "ClockMagnet.Clock.png");
            }
        }

        BitmapImage _thumbnail;

        public BitmapImage Thumbnail
        {
            get
            {
                if (_thumbnail == null)
                {
                    _thumbnail = Tools.GetBitmapImageFromFrameworkElement(this);
                }
                return _thumbnail;


                //return ResourcesAccess.GetBitmapImageFromResource("WeatherMagnet.Images.Thumbnail.png");
            }
        }

        public string MagnetName
        {
            get { return "Clock"; }
        }

        public void Terminate()
        {
            ObjectDataProvider odp = this.Resources["ClockEngineDS"] as ObjectDataProvider;
            ((ClockEngine)odp.ObjectInstance).Stop();
            Debug.WriteLine("Terminate Clock");
        }

        #endregion
    }
}